
package coffee;

/**
 *
 * @author bwolff
 */
class CodeTranslator {
    
    public String translateCommand(String cmd){
        // Workaround, no Int-String
        if(cmd.contains("Welcome")){
            return cmd;
        }
        String[] arrCmd = cmd.split(" ");
        String translated = "";
        int tmp;
        for (String val : arrCmd) {
            //System.out.println(val);
            tmp = Integer.parseInt(val);
            translated += getTranslation(tmp)+" ";
        }
        return translated;
    }
    public String getTranslation(int x){        
        switch(x){
            // general constants to begin a command with
            case Constants.MAKE: return "MAKE";
            case Constants.GET: return "GET";
            case Constants.FILL: return "FILL";       
            case Constants.EMPTY_GARBAGE: return "EMPTY_GARBAGE";
            case Constants.CLEAN_MACHINE: return "CLEAN MACHINE";
            case Constants.QUIT: return "QUIT";

            // constants for different beverages
            case Constants.COFFEE: return "COFFEE";
            case Constants.ESPRESSO: return "ESPRESSO";
            case Constants.CAPPUCCINO: return "CAPPUCCINO";
            case Constants.BLACK_TEA: return "BLACK_TEA";
            case Constants.GREEN_TEA: return "GREEN_TEA";
            case Constants.FRUIT_TEA: return "FRUIT_TEA";

            // constants for beans and extras
            case Constants.ARABICA: return "ARABICA";
            case Constants.ROBUSTA: return "ROBUSTA";
            case Constants.MILK: return "MILK";
            case Constants.HAZELNUT: return "HAZELNUT";
            case Constants.CARAMEL: return "CARAMEL";

            // constants for time
            case Constants.TIME: return "TIME";

            // constants for cupsizes
            case Constants.SMALL_CUP: return "SMALL_CUP";
            case Constants.MEDIUM_CUP: return "MEDIUM_CUP";
            case Constants.BIG_CUP: return "BIG_CUP";

            // constants for GET-command
            case Constants.PADS: return "PADS";
            case Constants.MAX_PADS: return "MAX_PADS";
            case Constants.NEEDED_PADS: return "NEEDED_PADS";
            case Constants.CAFFEINE: return "CAFFEINE";
            case Constants.EXTRA_LEVEL: return "EXTRA_LEVEL";
            case Constants.MAX_EXTRA_LEVEL: return "MAX_EXTRA_LEVEL";
            case Constants.NEEDED_EXTRA_LEVEL: return "NEEDED_EXTRA_LEVEL";
            case Constants.PRICE: return "PRICE";
            case Constants.GARBAGE_LEVEL: return "GARBAGE_LEVEL";
            case Constants.MAX_GARBAGE_LEVEL: return "MAX_GARBAGE_LEVEL";

            // constants for FILL-command:
            case Constants.ALL: return "ALL";
            case Constants.ALL_COFFEE: return "ALL_COFFEE";
            case Constants.ALL_TEA: return "ALL_TEA";
            case Constants.ALL_EXTRAS: return "ALL_EXTRAS";

            // constants for server replies:
            case Constants.ERROR: return "ERROR";
            case Constants.INFO: return "INFO";
            case Constants.WARNING: return "WARNING";
            case Constants.RANDOM_INFO: return "RANDOM_INFO";
            case Constants.ACCEPTED_COFFEE: return "ACCEPTED_COFFEE";
            case Constants.ACCEPTED_TEA: return "ACCEPTED_TEA";
            case Constants.TRUE: return "TRUE";
            case Constants.FALSE: return "FALSE";
            case Constants.READY_COFFEE: return "READY_COFFEE";
            case Constants.READY_TEA: return "READY_TEA";
            case Constants.FILLED: return "FILLED";
            case Constants.MACHINE_CLEANED: return "MACHINE_CLEANED";


            // constants for error/warning messages
            case Constants.EMPTY: return "EMPTY";
            case Constants.INSUFFICIANT: return "INSUFFICIANT";
            case Constants.GARBAGE_FULL: return "GARBAGE_FULL";
            case Constants.GARBAGE_INSUFFICIANT: return "GARBAGE_INSUFFICIANT";
            case Constants.COFFEE_IN_USE: return "COFFEE_IN_USE";
            case Constants.TEA_IN_USE: return "TEA_IN_USE";
            case Constants.INVALID_PARAMETER: return "INVALID_PARAMETER";
            case Constants.INVALID_COMMAND: return "INVALID_COMMAND";
            case Constants.NEEDS_CLEANING: return "NEEDS_CLEANING";
                
        }
        return String.valueOf(x);
    }
}